package com.minivision.sdktestdemo.ui.view;

import android.support.v7.app.AlertDialog;
import android.view.View;

import com.minivision.sdktestdemo.R;
import com.minivision.sdktestdemo.bean.MusicBean;
import com.minivision.sdktestdemo.utils.AlertDialogUtils;

/**
 * Created by devtang on 2016/5/14.
 */
public class PopClickItemFactory {

    public static class PopClickItem {
        private int mImageId;
        private String mContent;
        private View.OnClickListener mListener;

        public int getmImageId() {
            return mImageId;
        }

        public void setmImageId(int mImageId) {
            this.mImageId = mImageId;
        }

        public String getmContent() {
            return mContent;
        }

        public void setmContent(String mContent) {
            this.mContent = mContent;
        }

        public View.OnClickListener getmListener() {
            return mListener;
        }

        public void setmListener(View.OnClickListener mListener) {
            this.mListener = mListener;
        }
    }

    public interface OnDeleteListener {
        void onDelete(boolean isDeletedFlag);
    }

    public static PopClickItem getDeleteItem(final PopContentView view, final OnDeleteListener listener) {
        PopClickItem item = new PopClickItem();
        item.setmImageId(R.drawable.lay_icn_delete);
        item.setmContent("删除");
        item.setmListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                view.dismiss();
                AlertDialog dialog = AlertDialogUtils.getDeleteDialog(view.getContext(), listener, "确定将所选音乐从本地列表中移除吗?");
                dialog.show();
            }
        });
        return item;
    }

    public interface OnPlayListener {
        void onPlay();
    }

    public static PopClickItem getPlayItem(final PopContentView view, final OnPlayListener listener) {
        PopClickItem item = new PopClickItem();
        item.setmImageId(R.drawable.lay_icn_play);
        item.setmContent("播放");
        item.setmListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                view.dismiss();
                listener.onPlay();
            }
        });
        return item;
    }

    public interface OnSetRingListener {
        void onSetChanged();
    }

    public static PopClickItem getRingChangedItem(final PopContentView view, final OnSetRingListener listener) {
        PopClickItem item = new PopClickItem();
        item.setmImageId(R.drawable.lay_icn_ring);
        item.setmContent("设为铃声");
        item.setmListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                view.dismiss();
                listener.onSetChanged();
            }
        });
        return item;
    }

    public interface OnScanMusicListener {
        void onScanMusic();
    }

    public static PopClickItem getScanMusicItem(final PopContentView view, final OnScanMusicListener listener) {
        PopClickItem item = new PopClickItem();
        item.setmImageId(R.drawable.lay_icn_document);
        item.setmContent("查看歌曲信息");
        item.setmListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                view.dismiss();
                listener.onScanMusic();
            }
        });
        return item;
    }

    public interface OnMusicChangedListener {
        void onChanged();

        MusicBean getBean();
    }

    public static PopClickItem getInstance(String name) {
        return null;
    }
}
